package com.lz.football.module.guide.setting.view
{
	import com.liangzhong.events.AppEventDispatcher;
	import com.liangzhong.events.GuideEvent;
	import com.liangzhong.model.AppData;
	
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	
	import lz.controls.LButton;

	/**
	 *球员位置设置 
	 * @author lake
	 * 
	 */	
	public class PlaceSettingPanel extends GuideBaseSelectPanel
	{
		/**
		 * FW
		 */		
		private var itemBtn_1 :LButton;
		/**
		 * MF
		 */		
		private var itemBtn_2 :LButton;
		/**
		 * DF
		 */		
		private var itemBtn_3 :LButton;
		/**
		 *选择btn 
		 */		
		private var selectBtn :LButton;
		
		public function PlaceSettingPanel()
		{
			super();
		}
		/**
		 * 初始化
		 * @param view
		 * 
		 */		
		override public function initUI(view:Object=null):void
		{
			_symbolSkin = view as MovieClip;
			nextBtn = _symbolSkin.nextBtn;
			itemBtn_1 = new LButton(_symbolSkin.item_1);
			itemBtn_1.enable = true;
			itemBtn_1.buttonMode = true;
			itemBtn_1.data = 4;
			itemBtn_2 = new LButton(_symbolSkin.item_2);
			itemBtn_2.enable = true;
			itemBtn_2.buttonMode = true;
			itemBtn_2.data = 3;
			itemBtn_3 = new LButton(_symbolSkin.item_3);
			itemBtn_3.enable = true;
			itemBtn_3.buttonMode = true;
			itemBtn_3.data = 2;
			var tempArr :Array = [itemBtn_1,itemBtn_2,itemBtn_3];
			var ramIndex :int = Math.random() * 3;
			selectBtn = tempArr[ramIndex];
			selectBtn.enable = false;
			selectBtn.buttonMode = false;
			selectBtn.setStatus(LButton.SELECT);
			addEvtListener();
		}
		/**
		 * 添加事件
		 */		
		override public function addEvtListener():void
		{
			super.addEvtListener();
			itemBtn_1.addEventListener(MouseEvent.CLICK,clickHandler);
			itemBtn_2.addEventListener(MouseEvent.CLICK,clickHandler);
			itemBtn_3.addEventListener(MouseEvent.CLICK,clickHandler);
		}
		/**
		 *设置名字 
		 * 
		 */		
		public function setName():void
		{
			//默认名字
			_symbolSkin.item_1.mc.mc.txtName.text = AppData.getInstance().guideManager.guideSettingVo.clubName + "";
			_symbolSkin.item_2.mc.mc.txtName.text = AppData.getInstance().guideManager.guideSettingVo.clubName + "";
			_symbolSkin.item_3.mc.mc.txtName.text = AppData.getInstance().guideManager.guideSettingVo.clubName + "";
		}
		/**
		 *点击 
		 * @param e
		 * 
		 */		
		private function clickHandler(e :MouseEvent):void
		{
			if(selectBtn)
			{
				selectBtn.enable = true;
				selectBtn.buttonMode = true;
				selectBtn.setStatus(LButton.UP);
			}
			selectBtn = e.currentTarget as LButton;
			selectBtn.buttonMode = false;
			selectBtn.enable = false;
			selectBtn.setStatus(LButton.SELECT);
		}
		/**
		 * 删除事件
		 */		
		override public function removeEvtListener():void
		{
			super.removeEvtListener();
			itemBtn_1.removeEventListener(MouseEvent.CLICK,clickHandler);
			itemBtn_2.removeEventListener(MouseEvent.CLICK,clickHandler);
			itemBtn_3.removeEventListener(MouseEvent.CLICK,clickHandler);
		}
		/**
		 *下一步 
		 * @param e
		 * 
		 */		
		override protected function nextHandler(e :MouseEvent):void
		{
			AppEventDispatcher.getInstance().dispatchEvent(new GuideEvent(GuideEvent.PLACE_SELECT,selectBtn.data));
		}
	}
}